<?php

if (!defined('TOBBIVM'))
	header('location:/template/notrepassing.php');
/**
 * This file is part of TobbiVMShop.
 *
 * TobbiVMShop is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * TobbiVMShop is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with TobbiVMShop.  If not, see <http://www.gnu.org/licenses/>.
 */
/**
 * Create tax browse page
 * get tax.tpl.php
 *
 * @version    $Id$
 * @package    TobbiVM-Shop
 * @copyright  Copyright (C) 2012
 * @author     Norbert Gebert
 * @license    GPL3
 */
db::getInstance()->orderBy('tax_name', 'ASC');
$result = db::getInstance()->get('tax');

if (db::getInstance()->count <= 0)
{
	message::setErrorRow(_('Databaseerror! - Contact Admin!'), true);
}
else
{
	$refPage->assign('page_title', _('Tax settings'));
	$refPage->assign('summary', _('This table gives a overview of the Taxes'));

	$refPage->assign('tax_id', _('ID'));
	$refPage->assign('tax_name', _('Name'));
	$refPage->assign('tax_value', _('Value'));

	$refPage->assign('Form_Start',
		'<form class="niceform fieldset taxTable" action="' .
		'index2.php?page=' . $page . '&sub=' . $subpage .
		'" method="post"><fieldset>');
	$refPage->assign('Form_End', '</fieldset></form>');
	$data = NULL;

	foreach ($result as $buffer)
	{
		$tax_namey = '<a href="index2.php?page=' . $page . '&sub=' . $subpage .
			'&id=' . $buffer['tax_id'] . '&func=edit">' . $buffer['tax_name'] . '</a>';

		$data[] = array(
		 'tax_set' => '<input type="checkbox" name="marker[]" value="' . $buffer['tax_id'] . '" />',
		 'tax_idx' => $buffer['tax_id'],
		 'tax_namex' => $tax_namey,
		 'tax_valuex' => str_replace(".", ",", $buffer['tax_value']) . '%');
	}
	$refPage->assign('data', $data);

	$refPage->assign('btn_Delete',
		'<input type="submit" name="submit" id="delete" value="' .
		_('Delete') . '" />');
	$refPage->assign('btn_New',
		'<input type="submit" name="submit" id="new" value="' .
		_('New') . '" />');
	$refPage->assign('tableHelp', help('tax', $page, TRUE));

	$refPage->addtpl('content', '/' . $page . '/' . $subpage . '.tpl.php');
}
?>